According to Stroustrup (the C++ programming language) and the K&R C, the precedence of "<" is greater than the precedence of "!=", and all other references that we have agree with this. Since the two tests below return different results, MPW does not appear to be adhering to this rule. Both tests should succeed, but on MPW C++, test 1 fails. Under MPW 'C', this code works as it is supposed to.
------------------------------------------------------------------------- #include <stdio.h> main() { puts("Starting Tests..."); if (1 != 900 < 0) puts("Test 1 Worked"); else puts("Test 1 Failed"); if (1 != (900 < 0)) puts("Test 2 Worked"); else puts("Test 2 Failed"); } ------------------------------------------------------------------------- To compile: CPlus -o tmp.o tmp.c Link -o tmp tmp.o "{CLibraries}"StdClib.o "{CLibraries}"CSANElib.o 6 "{CLibraries}"Math.o 6 "{Libraries}"Runtime.o "{Libraries}"Interface.o 6 "{Libraries}"ToolLibs.o
You have two choices: either explicitly specify precedence by using (), or
switch to SCpp.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help